# !/usr/bin/env python
# -*- coding: utf-8 -*-
# @File  : 客户端：TCP长连接.py
# @Author: dongguangwen
# @Date  : 2025-01-05 9:56
import socket


client = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client.connect(('localhost', 12345))

try:
    while True:
        message = input('send:')
        client.sendall(message.encode('utf-8'))
        response = client.recv(1024)
        print(f'recv:{response.decode()}')
except KeyboardInterrupt:
    print('closing connection...')
finally:
    client.close()
